from urllib import urlopen
from datetime import *
import re

startdt = date(2007,1,1)
enddt = date(2009,12,30)
currentdt = startdt
dt = timedelta(days=1)
#pre = re.compile(r'FileSize:</b> (.*?)MB')
pre = re.compile(r'http\(s\).*?%.*?\( (.*?)%\)')
f = open('wide.html','w')
pk = []
while currentdt < enddt:
    path = currentdt.strftime('%Y%m%d')
    a = urlopen('http://mawi.wide.ad.jp/mawi/samplepoint-F/'+str(currentdt.year)+'/'+path+'1400.html').read()
    result = pre.search(a)
    try:
        pk.append(result.groups(0)[0])
        print result.groups(0)[0], currentdt
    except:
        print 'ERROR'
    currentdt+=dt

for i in xrange(1,len(pk)):
    f.write(pk[i-1]+','+pk[i]+'\n')
f.close()